<?php
if (isset($_POST)) {
	include('geshi.php');

	$source = stripslashes( $_POST['source'] );
	$lang = $_POST['lang'];
	$path = 'geshi/';

	$geshi = new GeSHi($source, $lang, $path);
	


    $geshi->set_overall_style('font-family: "Courier New", "Consolas", "Monaco", "Bitstream Vera Sans Mono", Courier, monospace !important;'
                            . 'border: 1px solid #d0d0d0; line-height: 1.2em !important; font-weight: normal !important;'
                            . 'font-style: normal !important; font-size: 1em !important; padding: 5px;', false);

    if (strtolower($lang) == 'php') {
        $geshi->language_data['STYLES'] = array(
            'KEYWORDS' => array(
                /*
                1 => 'color: #b1b100;',
                2 => 'color: #000000; font-weight: bold;',
                3 => 'color: #990000;',
                4 => 'color: #009900; font-weight: bold;'
                */
                1 => 'color: #0000ff;',
                2 => 'color: #0000ff;',
                3 => 'color: #0000ff;',
                4 => 'color: #0000ff;'
                ),
            'COMMENTS' => array(
                /*
                1 => 'color: #666666; font-style: italic;',
                2 => 'color: #666666; font-style: italic;',
                3 => 'color: #0000cc; font-style: italic;',
                4 => 'color: #009933; font-style: italic;',
                'MULTI' => 'color: #666666; font-style: italic;'
                */
                1 => 'color: rgb(128,128,128); font-style: italic;',
                2 => 'color: rgb(128,128,128); font-style: italic;',
                3 => 'color: rgb(128,128,128); font-style: italic;',
                4 => 'color: rgb(128,128,128); font-style: italic;',
                'MULTI' => 'color: rgb(128,128,128); font-style: italic;'
                ),
            'ESCAPE_CHAR' => array(
                0 => 'color: #000099; font-weight: bold;',
                1 => 'color: #000099; font-weight: bold;',
                2 => 'color: #660099; font-weight: bold;',
                3 => 'color: #660099; font-weight: bold;',
                4 => 'color: #006699; font-weight: bold;',
                5 => 'color: #006699; font-weight: bold; font-style: italic;',
                6 => 'color: #009933; font-weight: bold;',
                'HARD' => 'color: #000099; font-weight: bold;'
                ),
            'BRACKETS' => array(
                //0 => 'color: #009900;'
                0 => 'color: #000000;'
                ),
            'STRINGS' => array(
                /*
                0 => 'color: #0000ff;',
                'HARD' => 'color: #0000ff;'
                */
                0 => 'color: rgb(0, 130, 0);',
                'HARD' => 'color: rgb(0, 130, 0);'
                ),
            'NUMBERS' => array(
                0 => 'color: #cc66cc;',
                GESHI_NUMBER_OCT_PREFIX => 'color: #208080;',
                GESHI_NUMBER_HEX_PREFIX => 'color: #208080;',
                GESHI_NUMBER_FLT_SCI_ZERO => 'color:#800080;',
                ),
            'METHODS' => array(
                /*
                1 => 'color: #004000;',
                2 => 'color: #004000;'
                */
                1 => 'color: #000000;',
                2 => 'color: #000000;'
                ),
            'SYMBOLS' => array(
                /*
                0 => 'color: #339933;',
                1 => 'color: #000000; font-weight: bold;'
                */
                0 => 'color: #000000;',
                1 => 'color: #0000ff;'
                ),
            'REGEXPS' => array(
                //0 => 'color: #000088;'
                0 => 'color: rgb(102, 0, 0);'
                ),
            'SCRIPT' => array(
                0 => '',
                1 => '',
                2 => '',
                3 => '',
                4 => '',
                5 => ''
                ),
        );
    }

	if ($_POST['css_classes'] == 1) {
		$geshi->enable_classes();
		$styles = '<style type="text/css"><!--';
		$styles .= $geshi->get_stylesheet(true);
		$styles .= '	--></style>';
	} else {
		//$styles = NULL;
	}
	
	switch ($_POST['code_container']) {
		case 1:
			$geshi->set_header_type(GESHI_HEADER_NONE);
			break;
			
		case 2:
			$geshi->set_header_type(GESHI_HEADER_PRE);
			break;
			
		case 3:
			$geshi->set_header_type(GESHI_HEADER_DIV);
			break;
	}

	switch ($_POST['linenum']) {
		case 1:
			$geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
			break;
			
		case 2:
			$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
			break;
			
		case 3:
			$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
			break;
	}
	
	if (is_numeric($_POST['tabwidth'])) {
		$geshi->set_tab_width($_POST['tabwidth']);
	}

	//$geshi->set_overall_style('font-size:12px;',true);
	
	if (isset($styles)) {
        // when we need to get the style we open it
        //echo $styles;
    }
	
	echo $geshi->parse_code();
	
	
}

?>